package com.quik.web.front.service;

import java.util.Date;
import java.util.List;

import com.quik.entity.BizBilling;
import com.quik.entity.BizBillingItem;
import com.quik.entity.DtaProduct;
import com.quik.entity.SysAccount;
import com.quik.entity.VipAccount;

/**
 * 功能说明： 处理帐单相关的业务逻辑
 * 
 * @author Jenny
 * 
 */
public interface ConsultBillingService {
	/**
	 * 根据编号及编号类型查询关联的帐单
	 * 
	 * @param itemNo
	 * @param itemType
	 * @return
	 * @throws Exception
	 */
	public List findRelateBillingByItemNo(String itemNo, Integer itemType)
			throws Exception;

	/**
	 * 根据帐单ID查询所有帐单关联的房间
	 * 
	 * @param billingList
	 * @return
	 * @throws Exception
	 */
	public List findRelateRoomByBillingId(List billingList) throws Exception;

	/**
	 * 根据帐单ID查询所有帐单关联的手牌
	 * 
	 * @param billingList
	 * @return
	 * @throws Exception
	 */
	public List findRelateTokenByBillingId(List billingList) throws Exception;

	/**
	 * 根据帐单ID查询所有帐单关联的棋牌类消费
	 * 
	 * @param billingList
	 * @return
	 * @throws Exception
	 */
	public List findChessConsumeByBillingId(List billingList) throws Exception;

	/**
	 * 根据帐单ID查询所有帐单关联的服务类消费
	 * 
	 * @param billingList
	 * @return
	 * @throws Exception
	 */
	public List findServiceConsumeByBillingId(List billingList)
			throws Exception;

	/**
	 * 根据帐单ID查询所有帐单关联的其它类消费
	 * 
	 * @param billingList
	 * @return
	 * @throws Exception
	 */
	public List findOtherConsumeByBillingId(List billingList) throws Exception;

	/**
	 * 判断手牌或房间是否有效
	 * 
	 * @param roomNo
	 * @param tokenNo
	 * @return
	 * @throws Exception
	 */
	public boolean isValid(String roomNo, String tokenNo) throws Exception;

	/**
	 * 消费
	 * 
	 * @param productNo
	 *            规则：productNo;service;chess;qty
	 * @param roomNo
	 * @param tokenNo
	 * @param staffNo
	 * @return
	 * @throws Exception
	 */
	public Integer consume(String[] productNo, String roomNo, String tokenNo,
			String staffNo) throws Exception;

	/**
	 * 查询轮钟方式
	 * 
	 * @return
	 * @throws Exception
	 */
	public List findTurnTypeList() throws Exception;

	/**
	 * 分配技师
	 * 
	 * @param itemId
	 * @param subItemId
	 * @param workerNo
	 * @param turnType
	 * @param staffNo
	 * @throws Exception
	 */
	public void service(Integer itemId, Integer subItemId, String workerNo,
			String turnType, String staffNo) throws Exception;

	/**
	 * 起钟
	 * 
	 * @param itemId
	 * @param subItemId
	 * @param service
	 * @param chessRoom
	 * @param staffNo
	 * @return 返回起钟的时间
	 * @throws Exception
	 */
	public String start(Integer itemId, Integer subItemId, String service,
			String chessRoom, String staffNo) throws Exception;

	/**
	 * 授权验证
	 * 
	 * @param password
	 * @return
	 * @throws Exception
	 */
	public boolean isAuth(String operateAccount, String password)
			throws Exception;

	/**
	 * 是否允许撤单 （只有取消状态不允许撤单）
	 * 
	 * @param itemId
	 * @return 如果允许撤单返回true,否则返回false
	 * @throws Exception
	 */
	public boolean isOrder(Integer itemId) throws Exception;

	/**
	 * 撤单
	 * 
	 * @param itemId
	 * @param subItemId
	 * @param service
	 * @param chess
	 * @param staffNo
	 * @throws Exception
	 */
	public void cancelOrder(Integer itemId, Integer subItemId, String service,
			String chess, String staffNo) throws Exception;

	/**
	 * 落钟
	 * 
	 * @param itemId
	 * @param subItemId
	 * @param service
	 * @param chessRoom
	 * @param staffNo
	 * @return 返回结束时间
	 * @throws Exception
	 */
	public String end(Integer itemId, Integer subItemId, String service,
			String chessRoom, String staffNo) throws Exception;

	/**
	 * 反落钟
	 * 
	 * @param itemId
	 * @param subItemId
	 * @param service
	 * @param chessRoom
	 * @param staffNo
	 * @throws Exception
	 */
	public void reverseEnd(Integer itemId, Integer subItemId, String service,
			String chessRoom, String staffNo) throws Exception;

	/**
	 * 退钟
	 * 
	 * @param subItemId
	 * @param staffNo
	 * @throws Exception
	 */
	public void endCall(Integer subItemId, String staffNo) throws Exception;

	/**
	 * 更换技师
	 * 
	 * @param srcWorkerNo
	 * @param workerNo
	 * @param itemId
	 * @param subItemId
	 * @param staffNo
	 * @throws Exception
	 */
	public void exchangeWorker(String srcWorkerNo, String workerNo,
			Integer itemId, Integer subItemId, String staffNo) throws Exception;

	/**
	 * 根据手牌、房间以及帐单查询可供关联的帐单
	 * 
	 * @param itemNo
	 * @param itemType
	 * @return
	 * @throws Exception
	 */
	public List findRelateBilling(String itemNo, Integer itemType)
			throws Exception;

	/**
	 * 根据ITEM编号及类型判断所关联的帐单是否是主帐单
	 * 
	 * @param itemNo
	 * @return
	 */
	public BizBilling getRelateBilling(String itemNo, Integer itemType)
			throws Exception;

	/**
	 * 判断帐单是否是主帐单
	 * 
	 * @param bizBilling
	 * @return 主帐单则返回true， 否则返回false
	 * @throws Exception
	 */
	public boolean isMasterBilling(BizBilling bizBilling) throws Exception;

	/**
	 * 关联帐单
	 * 
	 * @param bizBilling
	 * @param billingIds
	 * @param billingNos
	 * @throws Exception
	 */
	public void relateBilling(BizBilling bizBilling, Integer[] billingIds,
			String[] billingNos, String staffNo) throws Exception;

	/**
	 * 根据帐单编号查询帐单（包括关联的所有帐单）
	 * 
	 * @param billingNo
	 * @return
	 * @throws Exception
	 */
	public List findRelateBillingByBillingNo(String billingNo) throws Exception;

	/**
	 * 判断要转移的帐号是否有效
	 * 
	 * @param billingType
	 * @param transferNo
	 * @return
	 * @throws Exception
	 */
	public boolean isValidBilling(Integer billingType, String transferNo)
			throws Exception;

	/**
	 * 转移单项帐单
	 * 
	 * @param itemId
	 * @param billingType
	 * @param transferNo
	 * @param staffNo
	 * @throws Exception
	 */
	public void transfer(Integer itemId, Integer billingType,
			String transferNo, String staffNo) throws Exception;

	/**
	 * 开发票
	 * 
	 * @param invoiceNo
	 * @param invoiceTitle
	 * @param invoiceAmount
	 * @param actualAmount
	 * @param staffNo
	 * @throws Exception
	 */
	public void addInvoice(String invoiceNo, String invoiceTitle,
			String invoiceAmount, String actualAmount, String staffNo)
			throws Exception;

	/**
	 * 设置营业日
	 * 
	 * @param staffNo
	 * @throws Exception
	 */
	public void updateBusinessDay(String staffNo) throws Exception;

	/**
	 * 取消帐单（全部）
	 * 
	 * @param billingIds
	 *            格式：billingId;billingId;
	 * @param staffNo
	 * @throws Exception
	 */
	public void cancelAll(String billingIds, String staffNo) throws Exception;

	/**
	 * 根据ITEM编号及类型查询帐单
	 * 
	 * @param itemNo
	 * @return
	 */
	public BizBilling getRelateBizBilling(String itemNo, Integer itemType)
			throws Exception;

	/**
	 * 查询未结帐帐单
	 * 
	 * @return
	 * @throws Exception
	 */
	public List findActiveBillingList() throws Exception;

	/**
	 * 根据帐单ID查询所有的帐单（包括包含的主帐单、关联帐单） 备注：需要考虑ID，有可能就是主帐单与其从帐单
	 * 
	 * @param billingNos
	 * @return
	 * @throws Exception
	 */
	public List findAllBillingListByBillingId(String[] billingNos)
			throws Exception;

	/**
	 * 查询付款方式
	 * 
	 * @return
	 * @throws Exception
	 */
	public List findPaymentTypeList() throws Exception;

	/**
	 * 根据VIP号查询VIP帐户
	 * 
	 * @param vipCard
	 * @return
	 * @throws Exception
	 */
	public VipAccount getVipAccount(String vipCard) throws Exception;

	/**
	 * 与当前日期比较大小
	 * 
	 * @param date
	 * @return 0 表示等于当前日期， 1表示大于日期，-1表示小于当前日期
	 * @throws Exception
	 */
	public int compareTime(Date date) throws Exception;

	/**
	 * 计算服务类的时间、总价、实际价 实际价是以实际为准
	 * 
	 * @param serviceList
	 * @throws Exception
	 */
	public void calcServicePrice(List serviceList, Integer productPriceType)
			throws Exception;

	/**
	 * 查询计价时间段类型
	 * 
	 * @return
	 * @throws Exception
	 */
	public int getProductPriceType() throws Exception;

	/**
	 * 根据产品编号查询编号
	 * 
	 * @param productNo
	 * @return
	 * @throws Exception
	 */
	public DtaProduct getProductByNo(String productNo) throws Exception;

	/**
	 * 计算棋牌的时间、总价、实际价 实际价是以实际为准
	 * 
	 * @param chessList
	 * @param productPriceType
	 * @throws Exception
	 */
	public void calcChessPrice(List chessList, Integer productPriceType)
			throws Exception;

	/**
	 * 计算其它类消 费的总价、实际价
	 * 
	 * @param otherList
	 * @throws Exception
	 */
	public void calcOtherPrice(List otherList) throws Exception;

	/**
	 * 求价格总和
	 * 
	 * @param serviceList
	 * @param chessList
	 * @param otherList
	 * @return
	 * @throws Exception
	 */
	public ConsultBillingServiceImpl.BillingPrice sum(List serviceList,
			List chessList, List otherList) throws Exception;

	/**
	 * 批量判断服务类、棋牌类是否都已是结束状态
	 * 
	 * @param serviceList
	 * @param chessList
	 * @return 有未结束状态返回false，其余返回true
	 * @throws Exception
	 */
	public boolean batchEndStatus(List serviceList, List chessList)
			throws Exception;

	/**
	 * 根据帐单编号构造虚拟的LIST，以便于进行消费查询
	 * 
	 * @param billingIds
	 *            格式：id;id
	 * @return
	 * @throws Exception
	 */
	public List<BizBilling> constructBizBillingList(String billingIds)
			throws Exception;

	/**
	 * 根据折扣/赠送重新再次计价
	 * 
	 * @param serviceList
	 * @param chessList
	 * @param otherList
	 */
	public void calcPrice(List serviceList, List chessList, List otherList,
			String[] billingItems) throws Exception;

	/**
	 * 支付
	 * 
	 * @param paymentType
	 * @param billingPrice
	 * @param actualAmount
	 * @param returnAmount
	 * @param vipCard
	 * @param billingList
	 * @param staffNo
	 * @throws Exception
	 */
	public void addPay(String paymentType,
			ConsultBillingServiceImpl.BillingPrice billingPrice,
			Integer actualAmount, Integer returnAmount, String vipCard,
			List billingList, List serviceList, List chessList, List otherList,
			String staffNo) throws Exception;

	/**
	 * 根据帐单ID更新手牌和房间状态
	 * 
	 * @param billingIds
	 * @throws Exception
	 */
	public void updateTokenOrRoomStatus(String billingIds, String staffNo)
			throws Exception;

	/**
	 * 根据帐单ID查找账单
	 * 
	 * @param billingIds
	 * @throws Exception
	 */
	public BizBilling findBillingByToken(String billingId) throws Exception;

	public List<BizBillingItem> findBillingItemByBillingId(String billingId)
			throws Exception;

	BizBilling findBillingById(String billingId) throws Exception;

	Integer addBillingItemByBillingId(Integer billingId, String[] productNos,
			Integer[] qtys, String roomNo, String tokenNo, String staffNo)
			throws Exception;

	String startByItemId(Integer billingItemId, String staffNo)
			throws Exception;
	
	void startProduct(Integer billingItemId, String tokenNo,
			Integer[] serviceIds, String[] workerNos, String[] turnTypes,
			String[] callTurnWorkerNos, SysAccount account) throws Exception;
}
